home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 25 / Cream of the Crop 25.iso / os2 / faxd_07.zip / RXIPC.ZIP / REXXIPC.INF (.txt) < prev    next >
OS/2 Help File  |  1995-06-24  |  46KB  |  2,374 lines

  1.  
  2. ΓòÉΓòÉΓòÉ 1. Copyright (c) Serge Brisson 1994, 1995 ΓòÉΓòÉΓòÉ
  3.  
  4. Copyright (c) Serge Brisson 1994, 1995.  All rights reserved. 
  5.  
  6.  
  7. Distribution 
  8.  
  9. The copyright owner allows the free distribution of the following files, as 
  10. long as they are kept together, unmodified: 
  11.  
  12.    o REXXIPC.DLL -- The library. 
  13.    o REXXIPC.INF -- The documentation. 
  14.    o REXXIPC.TXT -- Distribution text. 
  15.  
  16.  
  17. ΓòÉΓòÉΓòÉ 2. Introduction ΓòÉΓòÉΓòÉ
  18.  
  19. The RexxIPC library is designed to supply basic Inter Process Communication 
  20. capabilities for Rexx programs.  This is accomplished by supplying a near 
  21. one-to-one API to the Named Pipe, Event Semaphore, Mutex Semaphore and MuxWait 
  22. Semaphore OS/2 system services. 
  23.  
  24. The design requirements for this library specified support of multi-threaded 
  25. Rexx applications, support of access to the same IPC services by other C or C++ 
  26. functions, simplicity of use and non-interference in the application's design. 
  27.  
  28. Since the underlying system services already meet these requirements, the 
  29. library's design is mostly a straightforward Rexx interface to these services. 
  30. This document is supplied as a reference to this interface.  It assumes that 
  31. the reader has access to the Control Program Guide and Reference from the 
  32. Developer's Toolkit for OS/2. 
  33.  
  34. Note:   The explicit use of system handles in the Pipe interface allows the 
  35.         access to multiple instances of the same pipe (useful in a 
  36.         multi-threaded environment). 
  37.  
  38. The explicit use of system handles in the Semaphore interface allows the use of 
  39. unnamed semaphores. 
  40.  
  41.  
  42. ΓòÉΓòÉΓòÉ 3. IPC Procedures and Functions ΓòÉΓòÉΓòÉ
  43.  
  44. The IPC prefix identifies a few generic routines related to the operation of 
  45. the library. 
  46.  
  47. The IPCLoadFuncs and IPCDropFuncs register and deregister all the external 
  48. routines.  It is possible to be more specific by using the PipeLoadFuncs, 
  49. SemLoadFuncs and PipeDropFuncs, SemLoadFuncs procedures. 
  50.  
  51. The IPCVersion function returns a version identification string. 
  52.  
  53. The IPCContext functions are used to support threads and asynchronous services 
  54. (ProcCreateThread and PipeConnectAsync). 
  55.  
  56.  
  57. ΓòÉΓòÉΓòÉ 3.1. IPCContextClose function ΓòÉΓòÉΓòÉ
  58.  
  59.  
  60. Syntax 
  61.  
  62. rc = IPCContextClose(ctxHandle) 
  63.  
  64. Description 
  65.  
  66. IPCContextClose is used to free the memory resources consumed by the IPC 
  67. Context structure. 
  68.  
  69. Arguments 
  70.  
  71. ctxHandle      as obtained from IPCCreateContext. 
  72.  
  73.  Returns 
  74.  
  75.  IPCContextClose returns 0. 
  76.  
  77.  Notes 
  78.  
  79.  If a thread is still associated with the context when IPCContextClose is 
  80.  called, that thread is killed. 
  81.  
  82.  See also 
  83.  
  84.  IPCContextCreate 
  85.  
  86.  Examples 
  87.  
  88.  To close an IPC Context: 
  89.  
  90.       call IPCContextClose myContext
  91.       if result \= 0 then signal ContextCloseError
  92.  
  93.  
  94. ΓòÉΓòÉΓòÉ 3.2. IPCContextCreate function ΓòÉΓòÉΓòÉ
  95.  
  96.  
  97. Syntax 
  98.  
  99. rc = IPCContextCreate(handleVar, [ semHandle ]) 
  100.  
  101. Description 
  102.  
  103. IPCContextCreate is used to create a context for the execution of an 
  104. asynchronous (multi-threaded) function.  This context holds the completion 
  105. status and may hold an event semaphore handle to signal the completion of the 
  106. requested function.  It will also hold the result string returned by a thread 
  107. started with ProcCreateThread. 
  108.  
  109. Arguments 
  110.  
  111.  handleVar      is the name of the variable which is to receive the handle to 
  112.                 the allocated context. 
  113.  
  114.  semHandle      is the handle of the event semaphore which will be used to 
  115.                 signal the completion of the asynchronous function.  If this 
  116.                 semaphore is not supplied, the function IPCContextWait may be 
  117.                 used to wait for completion. 
  118.  
  119.  Returns 
  120.  
  121.  IPCContextCreate returns 0. 
  122.  
  123.  Notes 
  124.  
  125.  An IPCContext is a structure local to the RexxIPC library.  It consumes a few 
  126.  bytes and an internal event semaphore in the current process.  The memory and 
  127.  the semaphore is released by a call to IPCContextClose. 
  128.  
  129.  The internal event semaphore is used for thread synchronization and is not 
  130.  related to the optional semaphore supplied as an argument to this function. 
  131.  
  132.  See also 
  133.  
  134.  IPCContextClose, SemEventCreate, PipeConnectAsync, ProcCreateThread 
  135.  
  136.  Examples 
  137.  
  138.  To create an IPC Context: 
  139.  
  140.       call SemEventCreate 'myContextEvent'
  141.       if result \= 0 then signal SemCreateError
  142.       call IPCContextCreate 'myContext', myContextEvent
  143.       if result \= 0 then signal ContextCreateError
  144.       .
  145.       .
  146.       .
  147.       call IPCContextClose myContext
  148.       if result \= 0 then signal ContextCloseError
  149.       call SemEventClose myContextEvent
  150.       if result \= 0 then signal SemCloseError
  151.  
  152.  
  153. ΓòÉΓòÉΓòÉ 3.3. IPCContextQuery function ΓòÉΓòÉΓòÉ
  154.  
  155.  
  156. Syntax 
  157.  
  158. rc = IPCContextQuery(ctxHandle, [ threadVar ]) 
  159.  
  160. Description 
  161.  
  162. IPCContextQuery is used to get the completion code of the last thread 
  163. associated with the context.  If the thread is still active, the system Id may 
  164. be returned in an optional parameter. 
  165.  
  166. Arguments 
  167.  
  168.  ctxHandle      as obtained from IPCCreateContext. 
  169.  
  170.  threadVar      is the name of the variable which is to receive the system Id 
  171.                 of the thread active on the context.  If there is no such 
  172.                 thread, the value will be 0 (zero). 
  173.  
  174.  Returns 
  175.  
  176.  IPCContextQuery returns the completion code. 
  177.  
  178.  Notes 
  179.  
  180.  If a thread is still active on the context, IPCContextQuery will return the 
  181.  code ERROR_BUSY (170).  It will also put a non-zero value in the optional 
  182.  variable parameter. 
  183.  
  184.  See also 
  185.  
  186.  IPCContextCreate, IPCContextWait 
  187.  
  188.  Examples 
  189.  
  190.  To query an IPC Context used in a PipeConnectAsync: 
  191.  
  192.       call IPCContextQuery myContext
  193.       if result \= 0 then signal PipeConnectError
  194.  
  195.  
  196. ΓòÉΓòÉΓòÉ 3.4. IPCContextResult function ΓòÉΓòÉΓòÉ
  197.  
  198.  
  199. Syntax 
  200.  
  201. threadResult = IPCContextResult(ctxHandle) 
  202.  
  203. Description 
  204.  
  205. IPCContextResult is used to get the string returned by the thread associated 
  206. with the context. 
  207.  
  208. Arguments 
  209.  
  210.  ctxHandle      as obtained from IPCCreateContext. 
  211.  
  212.  Returns 
  213.  
  214.  IPCContextResult returns the string produced by the last Rexx thread 
  215.  associated with the context.  It will return a null string if the thread is 
  216.  still active or did not return a string. 
  217.  
  218.  See also 
  219.  
  220.  IPCContextCreate, IPCContextQuery, IPCContextWait, ProcCreateThread 
  221.  
  222.  Examples 
  223.  
  224.  To get the result from the last thread started by ProcCreateThread: 
  225.  
  226.       call IPCContextResult myContext
  227.       say 'The thread returned: "'result'".'
  228.  
  229.  
  230. ΓòÉΓòÉΓòÉ 3.5. IPCContextWait function ΓòÉΓòÉΓòÉ
  231.  
  232.  
  233. Syntax 
  234.  
  235. rc = IPCContextWait(ctxHandle) 
  236.  
  237. Description 
  238.  
  239. IPCContextWait is used to wait for the thread associated with the context and 
  240. get the completion code.  If the thread has already completed execution at the 
  241. time of the call, there will be no wait but the completion code will be 
  242. returned. 
  243.  
  244. Arguments 
  245.  
  246.  ctxHandle      as obtained from IPCCreateContext. 
  247.  
  248.  Returns 
  249.  
  250.  IPCContextWait returns the completion code. 
  251.  
  252.  Notes 
  253.  
  254.  After IPCContextWait returns, IPCContextResult may be called to get the string 
  255.  (if any) returned by the thread. 
  256.  
  257.  See also 
  258.  
  259.  IPCContextCreate, IPCContextQuery, IPCContextResult, ProcCreateThread 
  260.  
  261.  Examples 
  262.  
  263.  To wait for an IPC Context used in a PipeConnectAsync: 
  264.  
  265.       call IPCContextWait myContext
  266.       if result \= 0 then signal PipeConnectError
  267.  
  268.  
  269. ΓòÉΓòÉΓòÉ 3.6. IPCDropFuncs procedure ΓòÉΓòÉΓòÉ
  270.  
  271.  
  272. Syntax 
  273.  
  274. call IPCDropFuncs 
  275.  
  276. Description 
  277.  
  278. IPCDropFuncs deregisters all the library procedures and functions. 
  279.  
  280. Arguments 
  281.  
  282. No arguments are required by IPCDropFuncs. 
  283.  
  284. Returns 
  285.  
  286. Nothing is returned by IPCDropFuncs. 
  287.  
  288. Notes 
  289.  
  290. IPC procedures and functions may be deregistered individually.  IPCDropFuncs is 
  291. only a shortcut to have them all deregistered with one call. 
  292.  
  293. See also 
  294.  
  295. IPCLoadFuncs, PipeLoadFuncs, PipeDropFuncs, ProcLoadFuncs, ProcDropFuncs, 
  296. SemLoadFuncs, SemDropFuncs 
  297.  
  298.  
  299. ΓòÉΓòÉΓòÉ 3.7. IPCLoadFuncs procedure ΓòÉΓòÉΓòÉ
  300.  
  301.  
  302. Syntax 
  303.  
  304. call IPCLoadFuncs 
  305.  
  306. Description 
  307.  
  308. IPCLoadFuncs registers all the library procedures and functions. 
  309.  
  310. Arguments 
  311.  
  312. No arguments are required by IPCLoadFuncs. 
  313.  
  314. Returns 
  315.  
  316. Nothing is returned by IPCLoadFuncs. 
  317.  
  318. Notes 
  319.  
  320. IPC procedures and functions must be registered before they can be used.  They 
  321. may be registered individually.  IPCLoadFuncs is only a shortcut to have them 
  322. all registered with one call. 
  323.  
  324. See also 
  325.  
  326. IPCDropFuncs, PipeLoadFuncs, PipeDropFuncs, ProcLoadFuncs, ProcDropFuncs, 
  327. SemLoadFuncs, SemDropFuncs 
  328.  
  329. Examples 
  330.  
  331. To register all the RexxIPC functions: 
  332.  
  333.     call RxFuncAdd 'IPCLoadFuncs', 'REXXIPC', 'IPCLoadFuncs'
  334.     call IPCLoadFuncs
  335.  
  336.  
  337. ΓòÉΓòÉΓòÉ 3.8. IPCVersion function ΓòÉΓòÉΓòÉ
  338.  
  339.  
  340. Syntax 
  341.  
  342. versionString = IPCVersion() 
  343.  
  344. Description 
  345.  
  346. IPCVersion may be used to identify the version of the IPC library. 
  347.  
  348. Arguments 
  349.  
  350. No arguments are required by IPCVersion. 
  351.  
  352. Returns 
  353.  
  354. IPCVersion currently returns a string with the format producer product 
  355. major.minor-revision but this may change in the future. 
  356.  
  357.  
  358. ΓòÉΓòÉΓòÉ 4. Pipe Procedures and Functions ΓòÉΓòÉΓòÉ
  359.  
  360. The Pipe prefix identifies named pipe related functions.  Some of these are not 
  361. pipe specific in the operating system implementation (like DosRead used by 
  362. PipeRead, or DosClose used by PipeClose), but are needed for pipe operations. 
  363.  
  364. Some functions are most often used by the server side of an application (like 
  365. PipeCreate, PipeConnect and PipeDisconnect), while others are used by the 
  366. client side (like PipeOpen, PipeWait, PipeCall and PipeTransact). 
  367.  
  368. The "Control Program Guide and Reference" (Developer's Toolkit for OS/2) or 
  369. "Client/Server Programming with OS/2 2.0" (Van Nostrand Reinhold) are valuable 
  370. sources of information. 
  371.  
  372. Note:   The pipe handle mentionned in the individual Pipe functions description 
  373.         is the actual value used by the operating system, converted to an 
  374.         unsigned decimal number character string.  It is not associated with 
  375.         internal structures of the RexxIPC library and may be created/used by 
  376.         other modules of the same process. 
  377.  
  378.  
  379. ΓòÉΓòÉΓòÉ 4.1. PipeCall function ΓòÉΓòÉΓòÉ
  380.  
  381.  
  382. Syntax 
  383.  
  384. rc = PipeCall(name, output, inputVar, [ inputLimit ], [ timeout ]) 
  385.  
  386. Description 
  387.  
  388. PipeCall executes a call operation.  It combines the effect of PipeOpen, 
  389. PipeTransact and PipeClose. 
  390.  
  391. Arguments 
  392.  
  393.  name           specifies the name for the pipe. It must have the form: 
  394.  
  395.                     [\\serverName ]\PIPE\pipeName 
  396.  
  397.                 where: 
  398.  
  399.           serverName              is the name of the server on which the pipe 
  400.                                   has been created; 
  401.  
  402.           pipeName                is the actual name of the pipe. 
  403.  
  404.  output         is the string expression to be sent on the pipe. 
  405.  
  406.  inputVar       is the name of the variable which is to receive the response. 
  407.  
  408.  inputLimit     is the size limit (in bytes) for the response.  If zero or 
  409.                 omitted, a default of 4096 is used. 
  410.  
  411.  timeout        is the wait timeout in milliseconds.  The default is 50.  This 
  412.                 timeout refers to the time the directive will wait for a pipe 
  413.                 instance to become available. 
  414.  
  415.  Returns 
  416.  
  417.  PipeCall returns the code supplied by the DosCallNPipe system directive. 
  418.  
  419.  Notes 
  420.  
  421.  The named pipe must have been created in duplex mode with message format. 
  422.  
  423.  See also 
  424.  
  425.  PipeOpen, PipeWait, PipeTransact, PipeClose 
  426.  
  427.  Examples 
  428.  
  429.  To make a call on a named pipe: 
  430.  
  431.       call PipeCall '\PIPE\MY_SERVER_PIPE', 'Hello?', 'answer'
  432.       if result \= 0 then signal PipeCallError
  433.       say 'Pipe answer: "'answer'".'
  434.  
  435.  
  436. ΓòÉΓòÉΓòÉ 4.2. PipeClose function ΓòÉΓòÉΓòÉ
  437.  
  438.  
  439. Syntax 
  440.  
  441. rc = PipeClose(pipeHandle) 
  442.  
  443. Description 
  444.  
  445. PipeClose closes a pipe.  It is called both for a created pipe (server side), 
  446. and for an opened pipe (client side). 
  447.  
  448. Arguments 
  449.  
  450.  pipeHandle     as obtained from PipeCreate or PipeOpen. 
  451.  
  452.  Returns 
  453.  
  454.  PipeClose returns the code supplied by the DosClose system directive. 
  455.  
  456.  See also 
  457.  
  458.  PipeCreate, PipeOpen 
  459.  
  460.  Examples 
  461.  
  462.  To close a named pipe: 
  463.  
  464.       call PipeClose pipe
  465.       if result \= 0 then signal PipeCloseError
  466.  
  467.  
  468. ΓòÉΓòÉΓòÉ 4.3. PipeConnect function ΓòÉΓòÉΓòÉ
  469.  
  470.  
  471. Syntax 
  472.  
  473. rc = PipeConnect(pipeHandle) 
  474.  
  475. Description 
  476.  
  477. PipeConnect listens for a connection on a named pipe. 
  478.  
  479. Arguments 
  480.  
  481.  pipeHandle     as obtained from PipeCreate. 
  482.  
  483.  Returns 
  484.  
  485.  PipeConnect returns the code supplied by the DosConnectNPipe system directive. 
  486.  
  487.  See also 
  488.  
  489.  PipeCreate, PipeConnectAsync, PipeOpen, PipeDisconnect 
  490.  
  491.  Examples 
  492.  
  493.  To create a named pipe and listen for a connection: 
  494.  
  495.       call PipeCreate 'pipe', '\PIPE\MY_PIPE'
  496.       if result \= 0 then signal PipeCreateError
  497.  
  498.       call PipeConnect pipe
  499.       if result \= 0 then signal PipeConnectError
  500.  
  501.  To answer requests from PipeCall or PipeTransact calls: 
  502.  
  503.       call PipeCreate 'pipe', '\PIPE\MY_PIPE'
  504.       if result \= 0 then signal PipeCreateError
  505.  
  506.       do forever
  507.           call PipeConnect pipe
  508.           if result \= 0 then signal PipeConnectError
  509.  
  510.           do forever
  511.               call PipeRead pipe, 'request'
  512.               if result \= 0 then signal PipeReadError
  513.               if request = '' then leave
  514.               .
  515.               .
  516.               .
  517.               call PipeWrite pipe, 'answer'
  518.               if result \= 0 then signal PipeWriteError
  519.           end
  520.  
  521.           call PipeDisconnect pipe
  522.           if result \= 0 then signal PipeDisconnectError
  523.       end
  524.  
  525.  
  526. ΓòÉΓòÉΓòÉ 4.4. PipeConnectAsync function ΓòÉΓòÉΓòÉ
  527.  
  528.  
  529. Syntax 
  530.  
  531. rc = PipeConnectAsync(pipeHandle, ctxHandle) 
  532.  
  533. Description 
  534.  
  535. PipeConnectAsync listens for a connection on a named pipe. 
  536.  
  537. Arguments 
  538.  
  539.  pipeHandle     as obtained from PipeCreate. 
  540.  
  541.  ctxHandle      as obtained from IPCContextCreate. 
  542.  
  543.  Returns 
  544.  
  545.  PipeConnectAsync returns the code supplied by the DosCreateThread system 
  546.  directive. 
  547.  
  548.  See also 
  549.  
  550.  IPCContextCreate, PipeConnect, SemEventWait 
  551.  
  552.  Examples 
  553.  
  554.  To create a pipe and start a process which will immediately open the pipe: 
  555.  
  556.       call PipeCreate 'pipe', '\PIPE\REDIRECTED_INPUT'
  557.       if result \= 0 then signal PipeCreateError
  558.  
  559.       call IPCContextCreate 'context'
  560.       if result \= 0 then signal ContextCreateError
  561.  
  562.       call PipeConnectAsync pipe, context
  563.       if result \= 0 then signal PipeConnectAsyncError
  564.  
  565.       'DETACH RED_PROC <\PIPE\REDIRECTED_INPUT >NUL'
  566.  
  567.       call IPCContextWait context
  568.       if result \= 0 then signal PipeConnectError
  569.  
  570.  
  571. ΓòÉΓòÉΓòÉ 4.5. PipeCreate function ΓòÉΓòÉΓòÉ
  572.  
  573.  
  574. Syntax 
  575.  
  576. rc = PipeCreate(handleVar, name, [ mode ], [ format ], [ instances ], 
  577. [ outBufSize ], [ inpBufSize ], [ timeout ]) 
  578.  
  579. Description 
  580.  
  581. PipeCreate is used to create a named pipe. 
  582.  
  583. Arguments 
  584.  
  585.  handleVar      is the name of a variable which is to receive the handle to the 
  586.                 named pipe. 
  587.  
  588.  name           specifies the name for the pipe. It must have the form: 
  589.  
  590.                     \PIPE\pipeName 
  591.  
  592.                 where: 
  593.  
  594.           pipeName                is the actual name of the pipe. 
  595.  
  596.  mode           is the pipe access mode.  If present, it must be one of the 
  597.                 following keywords: 
  598.  
  599.           Inbound                 for an inbound pipe (receive only); 
  600.  
  601.           Outbound                for an outbound pipe (transmit only); 
  602.  
  603.           Duplex                  for a duplex pipe (transmit and receive), 
  604.                                   this is the default. 
  605.  
  606.                 The keywords are case insensitive and may be abbreviated. 
  607.  
  608.  format         is the pipe format.  If present, it must be one of the 
  609.                 following keywords: 
  610.  
  611.           Byte                    for a byte pipe (no implicit length); 
  612.  
  613.           Message                 for a message pipe (implicit length), this is 
  614.                                   the default. 
  615.  
  616.                 The keywords are case insensitive and may be abbreviated. 
  617.  
  618.  instances      is the maximum number of instances for this pipe.  It must be a 
  619.                 value between 1 and 255, or -1 (meaning no limit).  The default 
  620.                 is 1. 
  621.  
  622.  outBufSize     is the output buffer size.  The default is 1024. 
  623.  
  624.  inpBufSize     is the input buffer size.  The default is 1024. 
  625.  
  626.  timeout        is the default wait timeout in milliseconds.  The default is 
  627.                 50. 
  628.  
  629.  Returns 
  630.  
  631.  PipeCreate returns the code supplied by the DosCreateNPipe system directive. 
  632.  
  633.  Notes 
  634.  
  635.  If the return code is non-zero, handleVar is not created or modified. 
  636.  
  637.  See also 
  638.  
  639.  PipeOpen, PipeClose 
  640.  
  641.  Examples 
  642.  
  643.  To create a named pipe: 
  644.  
  645.       call PipeCreate 'pipe', '\PIPE\MY_PIPE'
  646.       if result \= 0 then signal PipeCreateError
  647.  
  648.  
  649. ΓòÉΓòÉΓòÉ 4.6. PipeDisconnect function ΓòÉΓòÉΓòÉ
  650.  
  651.  
  652. Syntax 
  653.  
  654. rc = PipeDisconnect(pipeHandle) 
  655.  
  656. Description 
  657.  
  658. PipeDisconnect drops a connection on a named pipe. 
  659.  
  660. Arguments 
  661.  
  662.  pipeHandle     as obtained from PipeCreate. 
  663.  
  664.  Returns 
  665.  
  666.  PipeDisconnect returns the code supplied by the DosDisConnectNPipe system 
  667.  directive. 
  668.  
  669.  See also 
  670.  
  671.  PipeCreate, PipeConnect 
  672.  
  673.  
  674. ΓòÉΓòÉΓòÉ 4.7. PipeDropFuncs procedure ΓòÉΓòÉΓòÉ
  675.  
  676.  
  677. Syntax 
  678.  
  679. call PipeDropFuncs 
  680.  
  681. Description 
  682.  
  683. PipeDropFuncs deregisters all the Pipe procedures and functions. 
  684.  
  685. Arguments 
  686.  
  687. No arguments are required by PipeDropFuncs. 
  688.  
  689. Returns 
  690.  
  691. Nothing is returned by PipeDropFuncs. 
  692.  
  693. Notes 
  694.  
  695. Pipe procedures and functions may be deregistered individually.  PipeDropFuncs 
  696. is only a shortcut to have them all deregistered with one call. 
  697.  
  698. IPCDropFuncs will by itself call PipeDropFuncs and deregister it. 
  699.  
  700. See also 
  701.  
  702. IPCDropFuncs, PipeLoadFuncs 
  703.  
  704.  
  705. ΓòÉΓòÉΓòÉ 4.8. PipeFlush function ΓòÉΓòÉΓòÉ
  706.  
  707.  
  708. Syntax 
  709.  
  710. rc = PipeFlush(pipeHandle) 
  711.  
  712. Description 
  713.  
  714. PipeFlush flushes the write buffer of a named pipe.  It may be called both for 
  715. a created pipe (server side), and for an opened pipe (client side). 
  716.  
  717. Arguments 
  718.  
  719.  pipeHandle     as obtained from PipeCreate or PipeOpen. 
  720.  
  721.  Returns 
  722.  
  723.  PipeFlush returns the code supplied by the DosFlush system directive. 
  724.  
  725.  See also 
  726.  
  727.  PipeClose 
  728.  
  729.  Examples 
  730.  
  731.  To flush a named pipe: 
  732.  
  733.       call PipeFlush pipe
  734.       if result \= 0 then signal PipeFlushError
  735.  
  736.  
  737. ΓòÉΓòÉΓòÉ 4.9. PipeLoadFuncs procedure ΓòÉΓòÉΓòÉ
  738.  
  739.  
  740. Syntax 
  741.  
  742. call PipeLoadFuncs 
  743.  
  744. Description 
  745.  
  746. PipeLoadFuncs registers all the Pipe procedures and functions. 
  747.  
  748. Arguments 
  749.  
  750. No arguments are required by PipeLoadFuncs. 
  751.  
  752. Returns 
  753.  
  754. Nothing is returned by PipeLoadFuncs. 
  755.  
  756. Notes 
  757.  
  758. Pipe procedures and functions must be registered before they can be used.  They 
  759. may be registered individually.  PipeLoadFuncs is only a shortcut to have them 
  760. all registered with one call. 
  761.  
  762. IPCLoadFuncs will by itself register and call PipeLoadFuncs. 
  763.  
  764. See also 
  765.  
  766. IPCLoadFuncs, PipeDropFuncs 
  767.  
  768.  
  769. ΓòÉΓòÉΓòÉ 4.10. PipeOpen function ΓòÉΓòÉΓòÉ
  770.  
  771.  
  772. Syntax 
  773.  
  774. rc = PipeOpen(handleVar, name, [ mode ], [ format ]) 
  775.  
  776. Description 
  777.  
  778. PipeOpen is used to open a named pipe. 
  779.  
  780. Arguments 
  781.  
  782.  handleVar      is the name of a variable which is to receive the handle to the 
  783.                 named pipe. 
  784.  
  785.  name           specifies the name for the pipe. It must have the form: 
  786.  
  787.                     [\\serverName ]\PIPE\pipeName 
  788.  
  789.                 where: 
  790.  
  791.           serverName              is the name of the server on which the pipe 
  792.                                   has been created; 
  793.  
  794.           pipeName                is the actual name of the pipe. 
  795.  
  796.  mode           is the pipe access mode.  If present, it must be one of the 
  797.                 following keywords: 
  798.  
  799.           Inbound                 for an inbound pipe (receive only); 
  800.  
  801.           Outbound                for an outbound pipe (transmit only); 
  802.  
  803.           Duplex                  for a duplex pipe (transmit and receive), 
  804.                                   this is the default. 
  805.  
  806.                 The keywords are case insensitive and may be abbreviated. 
  807.  
  808.  format         is the pipe format.  If present, it must be one of the 
  809.                 following keywords: 
  810.  
  811.           Byte                    for a byte pipe (no implicit length); 
  812.  
  813.           Message                 for a message pipe (implicit length), this is 
  814.                                   the default. 
  815.  
  816.                 The keywords are case insensitive and may be abbreviated. 
  817.  
  818.  Returns 
  819.  
  820.  PipeOpen returns the code supplied by the DosOpen system directive. 
  821.  
  822.  Notes 
  823.  
  824.  If the return code is non-zero, handleVar is not created or modified. 
  825.  
  826.  See also 
  827.  
  828.  PipeCreate, PipeClose 
  829.  
  830.  Examples 
  831.  
  832.  To open a named pipe: 
  833.  
  834.       call PipeOpen 'pipe', '\PIPE\MY_SERVER_PIPE'
  835.       if result \= 0 then signal PipeOpenError
  836.  
  837.  
  838. ΓòÉΓòÉΓòÉ 4.11. PipePeek function ΓòÉΓòÉΓòÉ
  839.  
  840.  
  841. Syntax 
  842.  
  843. rc = PipePeek(pipeHandle, [ inputVar ], [ inputLimit ], [ pipeBytesVar ], 
  844. [ msgBytesVar ], [ stateVar ]) 
  845.  
  846. Description 
  847.  
  848. PipePeek performs a read operation on a named pipe.  The operation returns 
  849. immediatly with the currently available data as well as with other requested 
  850. informations. 
  851.  
  852. Arguments 
  853.  
  854.  pipeHandle     as obtained from PipeCreate or PipeOpen. 
  855.  
  856.  inputVar       is the name of the variable which is to receive the data. 
  857.  
  858.  inputLimit     is the allowed size limit for the response.  If zero or 
  859.                 omitted, a default limit of 4096 is used. 
  860.  
  861.  pipeBytesVar   is the name of the variable which is to receive the number of 
  862.                 bytes held in the pipe buffer. 
  863.  
  864.  msgBytesVar    is the name of the variable which is to receive the number of 
  865.                 bytes held in the pipe buffer for the current message. 
  866.  
  867.  stateVar       is the name of the variable which is to receive a code 
  868.                 identifying the state of the pipe: 
  869.  
  870.           1:       the pipe is disconnected; 
  871.           2:       the pipe is listening for a connection; 
  872.           3:       the pipe is connected; 
  873.           4:       the pipe is closing. 
  874.  
  875.  Returns 
  876.  
  877.  PipePeek returns the code supplied by the DosPeekNPipe system directive. 
  878.  
  879.  See also 
  880.  
  881.  PipeRead 
  882.  
  883.  Examples 
  884.  
  885.  To peek for a maximum of 80 bytes from a named pipe: 
  886.  
  887.       call PipePeek pipe, 'data', 80, 'pipeBytes', 'msgBytes', 'state'
  888.       if result \= 0 then signal PipePeekError
  889.       say 'Pipe data:' data
  890.       say 'Pipe bytes held:' pipeBytes
  891.       say 'Pipe bytes in message:' msgBytes
  892.       say 'Pipe state:' state
  893.  
  894.  
  895. ΓòÉΓòÉΓòÉ 4.12. PipeRead function ΓòÉΓòÉΓòÉ
  896.  
  897.  
  898. Syntax 
  899.  
  900. rc = PipeRead(pipeHandle, inputVar, [ inputLimit ]) 
  901.  
  902. Description 
  903.  
  904. PipeRead performs a blocking read operation on a named pipe. 
  905.  
  906. Arguments 
  907.  
  908.  pipeHandle     as obtained from PipeCreate or PipeOpen. 
  909.  
  910.  inputVar       is the name of the variable which is to receive the data. 
  911.  
  912.  inputLimit     is the allowed size limit for the response.  If zero or 
  913.                 omitted, a default limit of 4096 is used. 
  914.  
  915.  Returns 
  916.  
  917.  PipeRead returns the code supplied by the DosRead system directive. 
  918.  
  919.  See also 
  920.  
  921.  PipeWrite, PipePeek 
  922.  
  923.  Examples 
  924.  
  925.  To read from a named pipe: 
  926.  
  927.       call PipeRead pipe, 'data'
  928.       if result \= 0 then signal PipeReadError
  929.       say 'Pipe data:' data
  930.  
  931.  
  932. ΓòÉΓòÉΓòÉ 4.13. PipeSetSem function ΓòÉΓòÉΓòÉ
  933.  
  934.  
  935. Syntax 
  936.  
  937. rc = PipeSetSem(pipeHandle, semHandle) 
  938.  
  939. Description 
  940.  
  941. PipeSetSem associates a shared event semaphore with the pipe.  Read and write 
  942. operations on the other end of the pipe will post events on that semaphore. 
  943.  
  944. Arguments 
  945.  
  946.  pipeHandle     as obtained from PipeCreate or PipeOpen. 
  947.  
  948.  semHandle      as obtained from SemEventCreate or SemEventOpen 
  949.  
  950.  Returns 
  951.  
  952.  PipeSetSem returns the code supplied by the DosSetNPipeSem system directive. 
  953.  
  954.  See also 
  955.  
  956.  SemEventCreate, SemEventWait, PipeRead, PipeWrite 
  957.  
  958.  Examples 
  959.  
  960.  To associate a shared event semaphore to a pipe: 
  961.  
  962.       call SemEventCreate 'event', 'Shared'
  963.       if result \= 0 then signal SemCreateError
  964.  
  965.       call PipeSetSem pipe, event
  966.       if result \= 0 then signal PipeSetSemError
  967.       .
  968.       .
  969.       .
  970.       call SemEventWait event
  971.       if result \= 0 then signal SemWaitError
  972.  
  973.  
  974. ΓòÉΓòÉΓòÉ 4.14. PipeTransact function ΓòÉΓòÉΓòÉ
  975.  
  976.  
  977. Syntax 
  978.  
  979. rc = PipeTransact(pipeHandle, output, inputVar, [ inputLimit ]) 
  980.  
  981. Description 
  982.  
  983. PipeTransact combines the effect of PipeWrite and PipeRead. 
  984.  
  985. Arguments 
  986.  
  987.  pipeHandle     as obtained from PipeCreate or PipeOpen. 
  988.  
  989.  output         is the string expression to be sent on the pipe. 
  990.  
  991.  inputVar       is the name of the variable which is to receive the response. 
  992.  
  993.  inputLimit     is the allowed size limit for the response.  If zero or 
  994.                 omitted, a default limit of 4096 is used. 
  995.  
  996.  Returns 
  997.  
  998.  PipeTransact returns the code supplied by the DosTransactNPipe system 
  999.  directive. 
  1000.  
  1001.  Notes 
  1002.  
  1003.  The pipe must have been created in duplex mode with message format. 
  1004.  
  1005.  See also 
  1006.  
  1007.  PipeCall, PipeRead, PipeWrite 
  1008.  
  1009.  Examples 
  1010.  
  1011.  To make a named pipe transaction: 
  1012.  
  1013.       call PipeTransact pipe, 'Hello?', 'answer'
  1014.       if result \= 0 then signal PipeTransactError
  1015.       say 'Pipe answer:' answer
  1016.  
  1017.  
  1018. ΓòÉΓòÉΓòÉ 4.15. PipeWait function ΓòÉΓòÉΓòÉ
  1019.  
  1020.  
  1021. Syntax 
  1022.  
  1023. rc = PipeWait(name, [ timeout ]) 
  1024.  
  1025. Description 
  1026.  
  1027. PipeWait performs a wait on a busy named pipe. 
  1028.  
  1029. Arguments 
  1030.  
  1031.  name           specifies the name for the pipe. It must have the form: 
  1032.  
  1033.                     [\\serverName ]\PIPE\pipeName 
  1034.  
  1035.                 where: 
  1036.  
  1037.           serverName              is the name of the server on which the pipe 
  1038.                                   has been created; 
  1039.  
  1040.           pipeName                is the actual name of the pipe. 
  1041.  
  1042.  timeout        is the wait timeout in milliseconds.  A value of -1 means an 
  1043.                 infinite wait; 0 or no value uses the value specified in the 
  1044.                 PipeCreate call. 
  1045.  
  1046.  Returns 
  1047.  
  1048.  PipeWait returns the code supplied by the DosWaitNPipe system directive. 
  1049.  
  1050.  See also 
  1051.  
  1052.  PipeOpen 
  1053.  
  1054.  Examples 
  1055.  
  1056.  To open a very busy named pipe: 
  1057.  
  1058.       do forever
  1059.           call PipeOpen 'pipe', '\PIPE\MY_SERVER_PIPE'
  1060.           if result = 0 then leave
  1061.           if result \= 231 then signal PipeOpenError
  1062.           call PipeWait '\PIPE\MY_SERVER_PIPE', -1
  1063.           if result \= 0 then signal PipeWaitError
  1064.       end
  1065.  
  1066.  
  1067. ΓòÉΓòÉΓòÉ 4.16. PipeWrite function ΓòÉΓòÉΓòÉ
  1068.  
  1069.  
  1070. Syntax 
  1071.  
  1072. rc = PipeWrite(pipeHandle, output) 
  1073.  
  1074. Description 
  1075.  
  1076. PipeWrite performs a blocking write operation on a named pipe. 
  1077.  
  1078. Arguments 
  1079.  
  1080.  pipeHandle     as obtained from PipeCreate or PipeOpen. 
  1081.  
  1082.  output         is the string expression to be sent on the pipe. 
  1083.  
  1084.  Returns 
  1085.  
  1086.  PipeWrite returns the code supplied by the DosWrite system directive. 
  1087.  
  1088.  See also 
  1089.  
  1090.  PipeRead 
  1091.  
  1092.  Examples 
  1093.  
  1094.  To write on a named pipe: 
  1095.  
  1096.       call PipeWrite pipe, 'Hello, Pipe!'
  1097.       if result \= 0 then signal PipeWriteError
  1098.  
  1099.  
  1100. ΓòÉΓòÉΓòÉ 5. Process Procedures and Functions ΓòÉΓòÉΓòÉ
  1101.  
  1102. The Proc prefix identifies process related functions. 
  1103.  
  1104. The "Control Program Guide and Reference" (Developer's Toolkit for OS/2) or 
  1105. "Client/Server Programming with OS/2 2.0" (Van Nostrand Reinhold) are valuable 
  1106. sources of information. 
  1107.  
  1108. Note:   The facilities provided by these functions are simple mapping to the 
  1109.         corresponding system services.  They should by used with caution, since 
  1110.         they are much more likely to affect other processes in the system than 
  1111.         the other function groups in this library. 
  1112.  
  1113.  
  1114. ΓòÉΓòÉΓòÉ 5.1. ProcCreateThread function ΓòÉΓòÉΓòÉ
  1115.  
  1116.  
  1117. Syntax 
  1118.  
  1119. rc = ProcCreateThread([ ctxHandle ], commandFile, [ ... ]) 
  1120.  
  1121. Description 
  1122.  
  1123. ProcCreateThread is used to create and start a Rexx thread. 
  1124.  
  1125. Arguments 
  1126.  
  1127.  ctxHandle      as obtained from IPCContextCreate.  This context is used to 
  1128.                 anchor the execution of the thread.  If this parameter is not 
  1129.                 supplied, a temporary context will be automatically generated 
  1130.                 before the thread is started and discarded after the thread has 
  1131.                 terminated. 
  1132.  
  1133.  commandFile    is the name of a Rexx command file to be executed by the Rexx 
  1134.                 interpreter in the thread. 
  1135.  
  1136.  ...            these parameters will be passed to the Rexx program. 
  1137.  
  1138.  Returns 
  1139.  
  1140.  ProcSendSignal returns the code supplied by the DosCreateThread system 
  1141.  directive. 
  1142.  
  1143.  Notes 
  1144.  
  1145.  The use of an explicit context allows for a more controlled execution of the 
  1146.  started thread.  It is then possible to specify an event semaphore to 
  1147.  IPCContextCreate which will be posted when the thread terminates, to 
  1148.  periodically check the thread with IPCContextQuery, to wait for the thread to 
  1149.  terminate and get the return code with IPCContextWait, to get the result 
  1150.  string returned by the thread with IPCContextResult, and to terminate the 
  1151.  thread with IPCContextClose. 
  1152.  
  1153.  Thread synchronization and resource access control may be done with Semaphore 
  1154.  functions.  The Rexx Queue facility (RxQueue and LineIn functions; Push, Pull 
  1155.  and Queue keywords) may be used to support communication between threads. 
  1156.  
  1157.  Examples 
  1158.  
  1159.  To start and forget a thread: 
  1160.  
  1161.       call ProcCreateThread , 'thread.cmd'
  1162.       if result \= 0 then signal CreateThreadError
  1163.  
  1164.  To start a thread, do some processing, then wait and get the thread result: 
  1165.  
  1166.       call IPCContextCreate 'context'
  1167.       if result \= 0 then signal CreateContextError
  1168.  
  1169.       call ProcCreateThread context, 'thread.cmd', '1st', '2nd'
  1170.       if result \= 0 then signal CreateThreadError
  1171.  
  1172.       .
  1173.       .
  1174.       .
  1175.  
  1176.       call IPCContextWait context
  1177.       if result \= 0 then signal ThreadTerminatedOnError
  1178.  
  1179.       call IPCContextResult context
  1180.       say 'The thread returned: "'result'".'
  1181.  
  1182.  
  1183. ΓòÉΓòÉΓòÉ 5.2. ProcDropFuncs procedure ΓòÉΓòÉΓòÉ
  1184.  
  1185.  
  1186. Syntax 
  1187.  
  1188. call ProcDropFuncs 
  1189.  
  1190. Description 
  1191.  
  1192. ProcDropFuncs deregisters all the process procedures and functions. 
  1193.  
  1194. Arguments 
  1195.  
  1196. No arguments are required by ProcDropFuncs. 
  1197.  
  1198. Returns 
  1199.  
  1200. Nothing is returned by ProcDropFuncs. 
  1201.  
  1202. Notes 
  1203.  
  1204. Process procedures and functions may be deregistered individually. 
  1205. ProcDropFuncs is only a shortcut to have them all deregistered with one call. 
  1206.  
  1207. IPCDropFuncs will by itself call ProcDropFuncs and deregister it. 
  1208.  
  1209. See also 
  1210.  
  1211. IPCDropFuncs, ProcLoadFuncs 
  1212.  
  1213.  
  1214. ΓòÉΓòÉΓòÉ 5.3. ProcLoadFuncs procedure ΓòÉΓòÉΓòÉ
  1215.  
  1216.  
  1217. Syntax 
  1218.  
  1219. call ProcLoadFuncs 
  1220.  
  1221. Description 
  1222.  
  1223. ProcLoadFuncs registers all the process procedures and functions. 
  1224.  
  1225. Arguments 
  1226.  
  1227. No arguments are required by ProcLoadFuncs. 
  1228.  
  1229. Returns 
  1230.  
  1231. Nothing is returned by ProcLoadFuncs. 
  1232.  
  1233. Notes 
  1234.  
  1235. Process procedures and functions must be registered before they can be used. 
  1236. They may be registered individually.  ProcLoadFuncs is only a shortcut to have 
  1237. them all registered with one call. 
  1238.  
  1239. IPCLoadFuncs will by itself register and call ProcLoadFuncs. 
  1240.  
  1241. See also 
  1242.  
  1243. IPCLoadFuncs, ProcDropFuncs 
  1244.  
  1245.  
  1246. ΓòÉΓòÉΓòÉ 5.4. ProcSendSignal function ΓòÉΓòÉΓòÉ
  1247.  
  1248.  
  1249. Syntax 
  1250.  
  1251. rc = ProcSendSignal(processId, signal) 
  1252.  
  1253. Description 
  1254.  
  1255. ProcSendSignal is used to send a signal (Break, Interrupt or Kill) to a 
  1256. process. 
  1257.  
  1258. Arguments 
  1259.  
  1260.  processId      is the process identification for the target process. 
  1261.  
  1262.  signal         identifies the signal to send.  It must be one of the following 
  1263.                 keywords: 
  1264.  
  1265.           Break                   send a Break (Ctrl+Break) signal; 
  1266.  
  1267.           Interrupt               send an Interrupt (Ctrl+C) signal; 
  1268.  
  1269.           Kill                    send a Kill signal. 
  1270.  
  1271.                 The keywords are case insensitive and may be abbreviated. 
  1272.  
  1273.  Returns 
  1274.  
  1275.  ProcSendSignal returns the code supplied by the DosSendSignalException or 
  1276.  DosKillProcess system directive. 
  1277.  
  1278.  Examples 
  1279.  
  1280.  To kill a process: 
  1281.  
  1282.       call ProcSendSignal processId, 'Kill'
  1283.       if result \= 0 then signal ProcessKillError
  1284.  
  1285.  
  1286. ΓòÉΓòÉΓòÉ 5.5. ProcSetPriority function ΓòÉΓòÉΓòÉ
  1287.  
  1288.  
  1289. Syntax 
  1290.  
  1291. rc = ProcSetPriority([ processId ], [ class ], [ delta ]) 
  1292.  
  1293. Description 
  1294.  
  1295. ProcSetPriority is used to modify the execution priority of a process. 
  1296.  
  1297. Arguments 
  1298.  
  1299.  processId      is the system identification for the target process.  Absence 
  1300.                 or 0 (zero) identifies the calling process. 
  1301.  
  1302.  class          is the new priority class.  If present, it must be one of the 
  1303.                 following keywords: 
  1304.  
  1305.           Idle                    identifies the Idle (lowest) priority class; 
  1306.  
  1307.           Regular                 identifies the Regular (default) priority 
  1308.                                   class; 
  1309.  
  1310.           Server                  identifies the Server (high) priority class; 
  1311.  
  1312.           Critical                identifies the Critical (highest) priority 
  1313.                                   class. 
  1314.  
  1315.                 The keywords are case insensitive and may be abbreviated. 
  1316.  
  1317.  delta          if the class is not specified, this is the priority variation 
  1318.                 within the current class and may range from -31 to +31;  if the 
  1319.                 class is specified, this is the absolute priority within that 
  1320.                 class and may range from 0 to +31. 
  1321.  
  1322.  Returns 
  1323.  
  1324.  ProcSetPriority returns the code supplied by the DosSetPriority system 
  1325.  directive. 
  1326.  
  1327.  See also 
  1328.  
  1329.  ProcSetThreadPriority, ProcSetTreePriority 
  1330.  
  1331.  Examples 
  1332.  
  1333.  To set the priority of the current process to 20 in the Idle class: 
  1334.  
  1335.       call ProcSetPriority 0, 'Idle', 20
  1336.       if result \= 0 then signal SetPriorityError
  1337.  
  1338.  
  1339. ΓòÉΓòÉΓòÉ 5.6. ProcSetThreadPriority function ΓòÉΓòÉΓòÉ
  1340.  
  1341.  
  1342. Syntax 
  1343.  
  1344. rc = ProcSetThreadPriority([ threadId ], [ class ], [ delta ]) 
  1345.  
  1346. Description 
  1347.  
  1348. ProcSetThreadPriority is used to modify the execution priority of a thread. 
  1349.  
  1350. Arguments 
  1351.  
  1352.  threadId       is the system identification for the target thread.  Absence or 
  1353.                 0 (zero) identifies the calling thread. 
  1354.  
  1355.  class          is the new priority class.  If present, it must be one of the 
  1356.                 following keywords: 
  1357.  
  1358.           Idle                    identifies the Idle (lowest) priority class; 
  1359.  
  1360.           Regular                 identifies the Regular (default) priority 
  1361.                                   class; 
  1362.  
  1363.           Server                  identifies the Server (high) priority class; 
  1364.  
  1365.           Critical                identifies the Critical (highest) priority 
  1366.                                   class. 
  1367.  
  1368.                 The keywords are case insensitive and may be abbreviated. 
  1369.  
  1370.  delta          if the class is not specified, this is the priority variation 
  1371.                 within the current class and may range from -31 to +31;  if the 
  1372.                 class is specified, this is the absolute priority within that 
  1373.                 class and may range from 0 to +31. 
  1374.  
  1375.  Returns 
  1376.  
  1377.  ProcSetThreadPriority returns the code supplied by the DosSetPriority system 
  1378.  directive. 
  1379.  
  1380.  See also 
  1381.  
  1382.  ProcSetPriority, ProcSetTreePriority 
  1383.  
  1384.  Examples 
  1385.  
  1386.  To set the priority of the current thread to 20 in the Idle class: 
  1387.  
  1388.       call ProcSetThreadPriority 0, 'Idle', 20
  1389.       if result \= 0 then signal SetPriorityError
  1390.  
  1391.  
  1392. ΓòÉΓòÉΓòÉ 5.7. ProcSetTreePriority function ΓòÉΓòÉΓòÉ
  1393.  
  1394.  
  1395. Syntax 
  1396.  
  1397. rc = ProcSetTreePriority([ processId ], [ class ], [ delta ]) 
  1398.  
  1399. Description 
  1400.  
  1401. ProcSetPriority is used to modify the execution priority of a process tree. 
  1402.  
  1403. Arguments 
  1404.  
  1405.  processId      is the system identification for the parent process of the 
  1406.                 target process tree.  Absence or 0 (zero) identifies the 
  1407.                 calling process as the parent. 
  1408.  
  1409.  class          is the new priority class.  If present, it must be one of the 
  1410.                 following keywords: 
  1411.  
  1412.           Idle                    identifies the Idle (lowest) priority class; 
  1413.  
  1414.           Regular                 identifies the Regular (default) priority 
  1415.                                   class; 
  1416.  
  1417.           Server                  identifies the Server (high) priority class; 
  1418.  
  1419.           Critical                identifies the Critical (highest) priority 
  1420.                                   class. 
  1421.  
  1422.                 The keywords are case insensitive and may be abbreviated. 
  1423.  
  1424.  delta          if the class is not specified, this is the priority variation 
  1425.                 within the current class and may range from -31 to +31;  if the 
  1426.                 class is specified, this is the absolute priority within that 
  1427.                 class and may range from 0 to +31. 
  1428.  
  1429.  Returns 
  1430.  
  1431.  ProcSetPriority returns the code supplied by the DosSetPriority system 
  1432.  directive. 
  1433.  
  1434.  See also 
  1435.  
  1436.  ProcSetPriority, ProcSetThreadPriority 
  1437.  
  1438.  Examples 
  1439.  
  1440.  To set the priority of the current process tree to 20 in the Idle class: 
  1441.  
  1442.       call ProcSetTreePriority 0, 'Idle', 20
  1443.       if result \= 0 then signal SetPriorityError
  1444.  
  1445.  
  1446. ΓòÉΓòÉΓòÉ 6. Semaphore Procedures and Functions ΓòÉΓòÉΓòÉ
  1447.  
  1448. The Sem prefix identifies semaphore related function.  Except for a few 
  1449. procedures (SemLoadFuncs and SemDropFuncs), the prefix is expressed as 
  1450. SemEvent, SemMutex or SemMuxwait, to specify to which type of semaphore the 
  1451. function applies. 
  1452.  
  1453. The "Control Program Guide and Reference" (Developer's Toolkit for OS/2) or 
  1454. "Client/Server Programming with OS/2 2.0" (Van Nostrand Reinhold) are valuable 
  1455. sources of information. 
  1456.  
  1457. Note:   The semaphore handle mentionned in the individual semaphore functions 
  1458.         description is the actual value used by the operating system, converted 
  1459.         to an unsigned decimal number character string.  It is not associated 
  1460.         with internal structures of the RexxIPC library and may be created/used 
  1461.         by other modules of the same process. 
  1462.  
  1463.  
  1464. ΓòÉΓòÉΓòÉ 6.1. SemDropFuncs procedure ΓòÉΓòÉΓòÉ
  1465.  
  1466.  
  1467. Syntax 
  1468.  
  1469. call SemDropFuncs 
  1470.  
  1471. Description 
  1472.  
  1473. SemDropFuncs deregisters all the semaphore procedures and functions. 
  1474.  
  1475. Arguments 
  1476.  
  1477. No arguments are required by SemDropFuncs. 
  1478.  
  1479. Returns 
  1480.  
  1481. Nothing is returned by SemDropFuncs. 
  1482.  
  1483. Notes 
  1484.  
  1485. Semaphore procedures and functions may be deregistered individually. 
  1486. SemDropFuncs is only a shortcut to have them all deregistered with one call. 
  1487.  
  1488. IPCDropFuncs will by itself call SemDropFuncs and deregister it. 
  1489.  
  1490. See also 
  1491.  
  1492. IPCLoadFuncs, IPCDropFuncs, SemLoadFuncs 
  1493.  
  1494.  
  1495. ΓòÉΓòÉΓòÉ 6.2. SemEventClose function ΓòÉΓòÉΓòÉ
  1496.  
  1497.  
  1498. Syntax 
  1499.  
  1500. rc = SemEventClose(semHandle) 
  1501.  
  1502. Description 
  1503.  
  1504. SemEventClose closes an event semaphore. 
  1505.  
  1506. Arguments 
  1507.  
  1508.  semHandle      as obtained from SemEventCreate or SemEventOpen. 
  1509.  
  1510.  Returns 
  1511.  
  1512.  SemEventClose returns the code supplied by the DosCloseEventSem system 
  1513.  directive. 
  1514.  
  1515.  See also 
  1516.  
  1517.  SemEventCreate, SemEventOpen 
  1518.  
  1519.  Examples 
  1520.  
  1521.  To close an event semaphore: 
  1522.  
  1523.       call SemEventClose sem
  1524.       if result \= 0 then signal SemCloseError
  1525.  
  1526.  
  1527. ΓòÉΓòÉΓòÉ 6.3. SemEventCreate function ΓòÉΓòÉΓòÉ
  1528.  
  1529.  
  1530. Syntax 
  1531.  
  1532. rc = SemEventCreate(handleVar, [ name ], [ initial ]) 
  1533.  
  1534. Description 
  1535.  
  1536. SemEventCreate is used to create an event semaphore. 
  1537.  
  1538. Arguments 
  1539.  
  1540.  handleVar      is the name of a variable which is to receive the handle to the 
  1541.                 event semaphore. 
  1542.  
  1543.  name           specifies the name for the semaphore. If present, it must have 
  1544.                 the form: 
  1545.  
  1546.                     \SEM32\semName 
  1547.  
  1548.                 where: 
  1549.  
  1550.           semName                 is the name of the semaphore. 
  1551.  
  1552.                 If a name is not specified, the keyword Shared (case 
  1553.                 insensitive and may be abbreviated) can be used to create a 
  1554.                 shared unnamed semaphore; otherwise a local semaphore is 
  1555.                 created. 
  1556.  
  1557.  initial        is the initial state of the event semaphore: posted (1) or 
  1558.                 reset (0).  The default is 0. 
  1559.  
  1560.  Returns 
  1561.  
  1562.  SemEventCreate returns the code supplied by the DosCreateEventSem system 
  1563.  directive. 
  1564.  
  1565.  Notes 
  1566.  
  1567.  If the return code is non-zero, handleVar is not created or modified. 
  1568.  
  1569.  See also 
  1570.  
  1571.  SemEventOpen, SemEventClose 
  1572.  
  1573.  Examples 
  1574.  
  1575.  To create an event semaphore or just open if it already exists: 
  1576.  
  1577.       semName = '\SEM32\MY_SEMAPHORE'
  1578.       call SemEventCreate 'sem', semName
  1579.       if result = 285 then call SemEventOpen 'sem', semName
  1580.       if result \= 0 then signal SemCreateError
  1581.  
  1582.  
  1583. ΓòÉΓòÉΓòÉ 6.4. SemEventOpen function ΓòÉΓòÉΓòÉ
  1584.  
  1585.  
  1586. Syntax 
  1587.  
  1588. rc = SemEventOpen(handleVar, name) 
  1589.  
  1590. Description 
  1591.  
  1592. SemEventOpen is used to open a named event semaphore. 
  1593.  
  1594. Arguments 
  1595.  
  1596.  handleVar      is the name of a variable which is to receive the handle to the 
  1597.                 event semaphore. 
  1598.  
  1599.  name           specifies the name for the semaphore. It must have the form: 
  1600.  
  1601.                     \SEM32\semName 
  1602.  
  1603.                 where: 
  1604.  
  1605.           semName                 is the name of the semaphore. 
  1606.  
  1607.  Returns 
  1608.  
  1609.  SemEventOpen returns the code supplied by the DosOpenEventSem system 
  1610.  directive. 
  1611.  
  1612.  Notes 
  1613.  
  1614.  If the return code is non-zero, handleVar is not created or modified. 
  1615.  
  1616.  See also 
  1617.  
  1618.  SemEventCreate, SemEventClose 
  1619.  
  1620.  Examples 
  1621.  
  1622.  To open a named event semaphore: 
  1623.  
  1624.       call SemEventOpen 'sem', '\SEM32\A_NAMED_SEMAPHORE'
  1625.       if result \= 0 then signal SemOpenError
  1626.  
  1627.  
  1628. ΓòÉΓòÉΓòÉ 6.5. SemEventPost function ΓòÉΓòÉΓòÉ
  1629.  
  1630.  
  1631. Syntax 
  1632.  
  1633. rc = SemEventPost(semHandle) 
  1634.  
  1635. Description 
  1636.  
  1637. SemEventPost posts an event semaphore. 
  1638.  
  1639. Arguments 
  1640.  
  1641.  semHandle      as obtained from SemEventCreate or SemEventOpen. 
  1642.  
  1643.  Returns 
  1644.  
  1645.  SemEventPost returns the code supplied by the DosPostEventSem system 
  1646.  directive. 
  1647.  
  1648.  See also 
  1649.  
  1650.  SemEventReset, SemEventQuery, SemEventWait 
  1651.  
  1652.  Examples 
  1653.  
  1654.  To post an event: 
  1655.  
  1656.       call SemEventPost sem
  1657.       if result \= 0 then signal SemPostError
  1658.  
  1659.  
  1660. ΓòÉΓòÉΓòÉ 6.6. SemEventQuery function ΓòÉΓòÉΓòÉ
  1661.  
  1662.  
  1663. Syntax 
  1664.  
  1665. rc = SemEventQuery(semHandle, postCountVar) 
  1666.  
  1667. Description 
  1668.  
  1669. SemEventQuery queries informations from an event semaphore. 
  1670.  
  1671. Arguments 
  1672.  
  1673.  semHandle      as obtained from SemEventCreate or SemEventOpen 
  1674.  
  1675.  postCountVar   is the name of the variable which is to hold the number of post 
  1676.                 actions since the last time the semaphore was in a reset state. 
  1677.  
  1678.  Returns 
  1679.  
  1680.  SemEventQuery returns the code supplied by the DosQueryEventSem system 
  1681.  directive. 
  1682.  
  1683.  See also 
  1684.  
  1685.  SemEventReset, SemEventPost, SemEventWait 
  1686.  
  1687.  Examples 
  1688.  
  1689.  To query an event semaphore: 
  1690.  
  1691.       call SemEventQuery sem, 'count'
  1692.       if result \= 0 then signal SemQueryError
  1693.       say 'Semaphore post count:' count
  1694.  
  1695.  
  1696. ΓòÉΓòÉΓòÉ 6.7. SemEventReset function ΓòÉΓòÉΓòÉ
  1697.  
  1698.  
  1699. Syntax 
  1700.  
  1701. rc = SemEventReset(semHandle, [ postCountVar ]) 
  1702.  
  1703. Description 
  1704.  
  1705. SemEventReset resets an event semaphore. 
  1706.  
  1707. Arguments 
  1708.  
  1709.  semHandle      as obtained from SemEventCreate or SemEventOpen. 
  1710.  
  1711.  postCountVar   if present, is the name of the variable which is to hold the 
  1712.                 number of post actions since the last time the semaphore was in 
  1713.                 a reset state. 
  1714.  
  1715.  Returns 
  1716.  
  1717.  SemEventReset returns the code supplied by the DosResetEventSem system 
  1718.  directive. 
  1719.  
  1720.  See also 
  1721.  
  1722.  SemEventPost, SemEventQuery, SemEventWait 
  1723.  
  1724.  Examples 
  1725.  
  1726.  To reset an event semaphore: 
  1727.  
  1728.       call SemEventReset sem
  1729.       if result \= 0 then signal SemResetError
  1730.  
  1731.  
  1732. ΓòÉΓòÉΓòÉ 6.8. SemEventWait function ΓòÉΓòÉΓòÉ
  1733.  
  1734.  
  1735. Syntax 
  1736.  
  1737. rc = SemEventWait(semHandle, [ timeout ]) 
  1738.  
  1739. Description 
  1740.  
  1741. SemEventWait waits for an event semaphore to be in a non reset state. 
  1742.  
  1743. Arguments 
  1744.  
  1745.  semHandle      as obtained from SemEventCreate or SemEventOpen. 
  1746.  
  1747.  timeout        is the wait timeout in milliseconds.  A value of -1 means an 
  1748.                 infinite wait;  this is the default. 
  1749.  
  1750.  Returns 
  1751.  
  1752.  SemEventWait returns the code supplied by the DosWaitEventSem system 
  1753.  directive. 
  1754.  
  1755.  See also 
  1756.  
  1757.  SemEventPost, SemEventReset, SemEventQuery 
  1758.  
  1759.  Examples 
  1760.  
  1761.  To wait for an event semaphore: 
  1762.  
  1763.       call SemEventWait sem
  1764.       if result \= 0 then signal SemWaitError
  1765.  
  1766.  
  1767. ΓòÉΓòÉΓòÉ 6.9. SemLoadFuncs procedure ΓòÉΓòÉΓòÉ
  1768.  
  1769.  
  1770. Syntax 
  1771.  
  1772. call SemLoadFuncs 
  1773.  
  1774. Description 
  1775.  
  1776. SemLoadFuncs registers all the semaphore procedures and functions. 
  1777.  
  1778. Arguments 
  1779.  
  1780. No arguments are required by SemLoadFuncs. 
  1781.  
  1782. Returns 
  1783.  
  1784. Nothing is returned by SemLoadFuncs. 
  1785.  
  1786. Notes 
  1787.  
  1788. Semaphore procedures and functions must be registered before they can be used. 
  1789. They may be registered individually.  SemLoadFuncs is only a shortcut to have 
  1790. them all registered with one call. 
  1791.  
  1792. IPCLoadFuncs will by itself register and call SemLoadFuncs. 
  1793.  
  1794. See also 
  1795.  
  1796. IPCLoadFuncs, SemDropFuncs 
  1797.  
  1798.  
  1799. ΓòÉΓòÉΓòÉ 6.10. SemMutexClose function ΓòÉΓòÉΓòÉ
  1800.  
  1801.  
  1802. Syntax 
  1803.  
  1804. rc = SemMutexClose(semHandle) 
  1805.  
  1806. Description 
  1807.  
  1808. SemMutexClose closes a mutex semaphore. 
  1809.  
  1810. Arguments 
  1811.  
  1812.  semHandle      as obtained from SemMutexCreate or SemMutexOpen. 
  1813.  
  1814.  Returns 
  1815.  
  1816.  SemMutexClose returns the code supplied by the DosCloseMutexSem system 
  1817.  directive. 
  1818.  
  1819.  See also 
  1820.  
  1821.  SemMutexCreate, SemMutexOpen 
  1822.  
  1823.  Examples 
  1824.  
  1825.  To close a mutex semaphore: 
  1826.  
  1827.       call SemMutexClose sem
  1828.       if result \= 0 then signal SemCloseError
  1829.  
  1830.  
  1831. ΓòÉΓòÉΓòÉ 6.11. SemMutexCreate function ΓòÉΓòÉΓòÉ
  1832.  
  1833.  
  1834. Syntax 
  1835.  
  1836. rc = SemMutexCreate(handleVar, [ name ], [ initial ]) 
  1837.  
  1838. Description 
  1839.  
  1840. SemMutexCreate is used to create a mutex semaphore. 
  1841.  
  1842. Arguments 
  1843.  
  1844.  handleVar      is the name of a variable which is to receive the handle to the 
  1845.                 mutex semaphore. 
  1846.  
  1847.  name           specifies the name for the semaphore. If present, it must have 
  1848.                 the form: 
  1849.  
  1850.                     \SEM32\semName 
  1851.  
  1852.                 where: 
  1853.  
  1854.           semName                 is the name of the semaphore. 
  1855.  
  1856.                 If a name is not specified, the keyword Shared (case 
  1857.                 insensitive and may be abbreviated) can be used to create a 
  1858.                 shared unnamed semaphore; otherwise a local semaphore is 
  1859.                 created. 
  1860.  
  1861.  initial        is the initial state of the mutex semaphore: held (1) or 
  1862.                 released (0).  The default is 0. 
  1863.  
  1864.  Returns 
  1865.  
  1866.  SemMutexCreate returns the code supplied by the DosCreateMutexSem system 
  1867.  directive. 
  1868.  
  1869.  Notes 
  1870.  
  1871.  If the return code is non-zero, handleVar is not created or modified. 
  1872.  
  1873.  See also 
  1874.  
  1875.  SemMutexOpen, SemMutexClose 
  1876.  
  1877.  Examples 
  1878.  
  1879.  To create a mutex semaphore: 
  1880.  
  1881.       call SemMutexCreate 'sem', '\SEM32\MY_SEMAPHORE'
  1882.       if result \= 0 then signal SemCreateError
  1883.  
  1884.  
  1885. ΓòÉΓòÉΓòÉ 6.12. SemMutexOpen function ΓòÉΓòÉΓòÉ
  1886.  
  1887.  
  1888. Syntax 
  1889.  
  1890. rc = SemMutexOpen(handleVar, name) 
  1891.  
  1892. Description 
  1893.  
  1894. SemMutexOpen is used to open a named mutex semaphore. 
  1895.  
  1896. Arguments 
  1897.  
  1898.  handleVar      is the name of a variable which is to receive the handle to the 
  1899.                 mutex semaphore. 
  1900.  
  1901.  name           specifies the name for the semaphore. It must have the form: 
  1902.  
  1903.                     \SEM32\semName 
  1904.  
  1905.                 where: 
  1906.  
  1907.           semName                 is the name of the semaphore. 
  1908.  
  1909.  Returns 
  1910.  
  1911.  SemMutexOpen returns the code supplied by the DosOpenMutexSem system 
  1912.  directive. 
  1913.  
  1914.  Notes 
  1915.  
  1916.  If the return code is non-zero, handleVar is not created or modified. 
  1917.  
  1918.  See also 
  1919.  
  1920.  SemMutexCreate, SemMutexClose 
  1921.  
  1922.  Examples 
  1923.  
  1924.  To open a named mutex semaphore: 
  1925.  
  1926.       call SemMutexOpen 'sem', '\SEM32\A_NAMED_SEMAPHORE'
  1927.       if result \= 0 then signal SemOpenError
  1928.  
  1929.  
  1930. ΓòÉΓòÉΓòÉ 6.13. SemMutexQuery function ΓòÉΓòÉΓòÉ
  1931.  
  1932.  
  1933. Syntax 
  1934.  
  1935. rc = SemMutexQuery(semHandle, [ processIdVar ], [ threadIdVar ], [ countVar ]) 
  1936.  
  1937. Description 
  1938.  
  1939. SemMutexQuery queries informations from a mutex semaphore. 
  1940.  
  1941. Arguments 
  1942.  
  1943.  semHandle      as obtained from SemMutexCreate or SemMutexOpen. 
  1944.  
  1945.  processIdVar   if present, is the name of the variable which is to hold the id 
  1946.                 of the owner process. 
  1947.  
  1948.  threadIdVar    if present, is the name of the variable which is to hold the id 
  1949.                 of the owner thread. 
  1950.  
  1951.  countVar       if present, is the name of the variable which is to hold the 
  1952.                 request count from the owner process.  If the semaphore is 
  1953.                 unowned, the count is zero. 
  1954.  
  1955.  Returns 
  1956.  
  1957.  SemMutexQuery returns the code supplied by the DosQueryMutexSem system 
  1958.  directive. 
  1959.  
  1960.  See also 
  1961.  
  1962.  SemMutexRequest, SemMutexRelease 
  1963.  
  1964.  Examples 
  1965.  
  1966.  To query a mutex semaphore: 
  1967.  
  1968.       call SemMutexQuery sem, 'processId', 'threadId', 'count'
  1969.       if result \= 0 then signal SemQueryError
  1970.       say 'Semaphore post count:' count
  1971.       if count \= 0 then
  1972.       do
  1973.           say 'Semaphore owner process:' processId
  1974.           say 'Semaphore owner thread:' threadId
  1975.       end
  1976.  
  1977.  
  1978. ΓòÉΓòÉΓòÉ 6.14. SemMutexRelease function ΓòÉΓòÉΓòÉ
  1979.  
  1980.  
  1981. Syntax 
  1982.  
  1983. rc = SemMutexRelease(semHandle) 
  1984.  
  1985. Description 
  1986.  
  1987. SemMutexRelease releases a mutex semaphore. 
  1988.  
  1989. Arguments 
  1990.  
  1991.  semHandle      as obtained from SemMutexCreate or SemMutexOpen. 
  1992.  
  1993.  Returns 
  1994.  
  1995.  SemMutexRelease returns the code supplied by the DosReleaseMutexSem system 
  1996.  directive. 
  1997.  
  1998.  See also 
  1999.  
  2000.  SemMutexRequest, SemMutexQuery 
  2001.  
  2002.  Examples 
  2003.  
  2004.  To release a mutex semaphore: 
  2005.  
  2006.       call SemMutexRelease sem
  2007.       if result \= 0 then signal SemReleaseError
  2008.  
  2009.  
  2010. ΓòÉΓòÉΓòÉ 6.15. SemMutexRequest function ΓòÉΓòÉΓòÉ
  2011.  
  2012.  
  2013. Syntax 
  2014.  
  2015. rc = SemMutexRequest(semHandle, [ timeout ]) 
  2016.  
  2017. Description 
  2018.  
  2019. SemMutexRequest requests to be the owner of a mutex semaphore. 
  2020.  
  2021. Arguments 
  2022.  
  2023.  semHandle      as obtained from SemMutexCreate or SemMutexOpen. 
  2024.  
  2025.  timeout        is the wait timeout in milliseconds.  A value of -1 means an 
  2026.                 infinite wait;  this is the default. 
  2027.  
  2028.  Returns 
  2029.  
  2030.  SemMutexRequest returns the code supplied by the DosRequestMutexSem system 
  2031.  directive. 
  2032.  
  2033.  See also 
  2034.  
  2035.  SemMutexCreate, SemMutexRelease, SemMutexQuery 
  2036.  
  2037.  Examples 
  2038.  
  2039.  To request a mutex semaphore: 
  2040.  
  2041.       call SemMutexRequest sem
  2042.       if result \= 0 then signal SemRequestError
  2043.  
  2044.  
  2045. ΓòÉΓòÉΓòÉ 6.16. SemMuxwaitAdd function ΓòÉΓòÉΓòÉ
  2046.  
  2047.  
  2048. Syntax 
  2049.  
  2050. rc = SemMuxwaitAdd(semHandle, otherSemHandle, [ userValue ]) 
  2051.  
  2052. Description 
  2053.  
  2054. SemMuxwaitAdd adds a semaphore to the associated semaphores list. 
  2055.  
  2056. Arguments 
  2057.  
  2058.  semHandle      as obtained from SemMuxwaitCreate or SemMuxwaitOpen. 
  2059.  
  2060.  otherSemHandle as obtained from SemEventCreate, SemEventOpen, SemMutexCreate, 
  2061.                 or SemMutexOpen. 
  2062.  
  2063.  userValue      a numeric value to be returned by SemMuxwaitWait. 
  2064.  
  2065.  Returns 
  2066.  
  2067.  SemMuxwaitAdd returns the code supplied by the DosAddMuxWaitSem system 
  2068.  directive. 
  2069.  
  2070.  See also 
  2071.  
  2072.  SemMuxwaitCreate, SemMuxwaitOpen, SemMuxwaitRemove, SemEventCreate, 
  2073.  SemEventOpen, SemMutexCreate, SemMutexOpen 
  2074.  
  2075.  Examples 
  2076.  
  2077.  To add an event semaphore to a muxwait semaphore: 
  2078.  
  2079.       call SemEventCreate 'eventSem'
  2080.       if result \= 0 then signal SemCreateError
  2081.       call SemMuxwaitAdd muxSem, eventSem, 1
  2082.       if result \= 0 then signal SemAddError
  2083.  
  2084.  
  2085. ΓòÉΓòÉΓòÉ 6.17. SemMuxwaitClose function ΓòÉΓòÉΓòÉ
  2086.  
  2087.  
  2088. Syntax 
  2089.  
  2090. rc = SemMuxwaitClose(semHandle) 
  2091.  
  2092. Description 
  2093.  
  2094. SemMuxwaitClose closes a muxwait semaphore. 
  2095.  
  2096. Arguments 
  2097.  
  2098.  semHandle      as obtained from SemMuxwaitCreate or SemMuxwaitOpen. 
  2099.  
  2100.  Returns 
  2101.  
  2102.  SemMuxwaitClose returns the code supplied by the DosCloseMuxWaitSem system 
  2103.  directive. 
  2104.  
  2105.  See also 
  2106.  
  2107.  SemMuxwaitCreate, SemMuxwaitOpen 
  2108.  
  2109.  Examples 
  2110.  
  2111.  To close a muxwait semaphore: 
  2112.  
  2113.       call SemMuxwaitClose sem
  2114.       if result \= 0 then signal SemCloseError
  2115.  
  2116.  
  2117. ΓòÉΓòÉΓòÉ 6.18. SemMuxwaitCreate function ΓòÉΓòÉΓòÉ
  2118.  
  2119.  
  2120. Syntax 
  2121.  
  2122. rc = SemMuxwaitCreate(handleVar, [ name ], mode) 
  2123.  
  2124. Description 
  2125.  
  2126. SemMuxwaitCreate is used to create a muxwait semaphore. 
  2127.  
  2128. Arguments 
  2129.  
  2130.  handleVar      is the name of a variable which is to receive the handle to the 
  2131.                 muxwait semaphore. 
  2132.  
  2133.  name           specifies the name for the semaphore. If present, it must have 
  2134.                 the form: 
  2135.  
  2136.                     \SEM32\semName 
  2137.  
  2138.                 where: 
  2139.  
  2140.           semName                 is the name of the semaphore. 
  2141.  
  2142.                 If a name is not specified, the keyword Shared (case 
  2143.                 insensitive and may be abbreviated) can be used to create a 
  2144.                 shared unnamed semaphore; otherwise a local semaphore is 
  2145.                 created. 
  2146.  
  2147.  mode           is the muxwait semaphore wait mode.  It must be one of the 
  2148.                 following keywords: 
  2149.  
  2150.           And                     wait for all associated semaphores; 
  2151.  
  2152.           Or                      wait for any associated semaphore. 
  2153.  
  2154.                 The keywords are case insensitive and may be abbreviated. 
  2155.  
  2156.  Returns 
  2157.  
  2158.  SemMuxwaitCreate returns the code supplied by the DosCreateMuxWaitSem system 
  2159.  directive. 
  2160.  
  2161.  Notes 
  2162.  
  2163.  If the return code is non-zero, handleVar is not created or modified. 
  2164.  
  2165.  See also 
  2166.  
  2167.  SemMuxwaitAdd, SemMuxwaitOpen, SemMuxwaitClose SemMuxwaitWait, 
  2168.  
  2169.  Examples 
  2170.  
  2171.  To create a muxwait semaphore: 
  2172.  
  2173.       call SemMuxwaitCreate 'sem', '\SEM32\MY_MUXWAIT_SEM', 'Or'
  2174.       if result \= 0 then signal SemCreateError
  2175.  
  2176.  
  2177. ΓòÉΓòÉΓòÉ 6.19. SemMuxwaitOpen function ΓòÉΓòÉΓòÉ
  2178.  
  2179.  
  2180. Syntax 
  2181.  
  2182. rc = SemMuxwaitOpen(handleVar, name) 
  2183.  
  2184. Description 
  2185.  
  2186. SemMutexOpen is used to open a named muxwait semaphore. 
  2187.  
  2188. Arguments 
  2189.  
  2190.  handleVar      is the name of a variable which is to receive the handle to the 
  2191.                 muxwait semaphore. 
  2192.  
  2193.  name           specifies the name for the semaphore. It must have the form: 
  2194.  
  2195.                     \SEM32\semName 
  2196.  
  2197.                 where: 
  2198.  
  2199.           semName                 is the name of the semaphore. 
  2200.  
  2201.  Returns 
  2202.  
  2203.  SemMuxwaitOpen returns the code supplied by the DosOpenMuxWaitSem system 
  2204.  directive. 
  2205.  
  2206.  Notes 
  2207.  
  2208.  If the return code is non-zero, handleVar is not created or modified. 
  2209.  
  2210.  See also 
  2211.  
  2212.  SemMuxwaitCreate, SemMuxwaitClose 
  2213.  
  2214.  Examples 
  2215.  
  2216.  To open a named muxwait semaphore: 
  2217.  
  2218.       call SemMuxwaitOpen 'sem', '\SEM32\A_NAMED_MUXWAIT_SEM'
  2219.       if result \= 0 then signal SemOpenError
  2220.  
  2221.  
  2222. ΓòÉΓòÉΓòÉ 6.20. SemMuxwaitRemove function ΓòÉΓòÉΓòÉ
  2223.  
  2224.  
  2225. Syntax 
  2226.  
  2227. rc = SemMuxwaitRemove(semHandle, otherSemHandle) 
  2228.  
  2229. Description 
  2230.  
  2231. SemMuxwaitRemove removes a semaphore from the associated semaphores list. 
  2232.  
  2233. Arguments 
  2234.  
  2235.  semHandle      as obtained from SemMuxwaitCreate or SemMuxwaitOpen. 
  2236.  
  2237.  otherSemHandle as obtained from SemEventCreate, SemEventOpen, SemMutexCreate, 
  2238.                 or SemMutexOpen. 
  2239.  
  2240.  Returns 
  2241.  
  2242.  SemMuxwaitRemove returns the code supplied by the DosDeleteMuxWaitSem system 
  2243.  directive. 
  2244.  
  2245.  See also 
  2246.  
  2247.  SemMuxwaitAdd 
  2248.  
  2249.  Examples 
  2250.  
  2251.  To remove an event semaphore from a muxwait semaphore: 
  2252.  
  2253.       call SemMuxwaitRemove muxSem, eventSem
  2254.       if result \= 0 then signal SemRemoveError
  2255.  
  2256.  
  2257. ΓòÉΓòÉΓòÉ 6.21. SemMuxwaitWait function ΓòÉΓòÉΓòÉ
  2258.  
  2259.  
  2260. Syntax 
  2261.  
  2262. rc = SemMuxwaitWait(semHandle, [ timeout ], [ userVar ]) 
  2263.  
  2264. Description 
  2265.  
  2266. SemMuxwaitWait waits for a muxwait semaphore. 
  2267.  
  2268. Arguments 
  2269.  
  2270.  semHandle      as obtained from SemMuxwaitCreate or SemMuxwaitOpen. 
  2271.  
  2272.  timeout        is the wait timeout in milliseconds.  A value of -1 means an 
  2273.                 infinite wait;  this is the default. 
  2274.  
  2275.  userVar        is the name of a variable which is to receive the optional 
  2276.                 value specified with the SemMuxwaitAdd function. 
  2277.  
  2278.  Returns 
  2279.  
  2280.  SemMuxwaitWait returns the code supplied by the DosWaitMuxWaitSem system 
  2281.  directive. 
  2282.  
  2283.  See also 
  2284.  
  2285.  SemMuxwaitAdd 
  2286.  
  2287.  Examples 
  2288.  
  2289.  To wait for a muxwait semaphore: 
  2290.  
  2291.       call SemMuxwaitWait sem
  2292.       if result \= 0 then signal SemWaitError
  2293.  
  2294.  
  2295. ΓòÉΓòÉΓòÉ 6.22. SemStartTimer function ΓòÉΓòÉΓòÉ
  2296.  
  2297.  
  2298. Syntax 
  2299.  
  2300. rc = SemStartTimer([ handleVar ], interval, semHandle, [ type ]) 
  2301.  
  2302. Description 
  2303.  
  2304. SemStartTimer is used to create and start a timer which will post a shared 
  2305. event semaphore. 
  2306.  
  2307. Arguments 
  2308.  
  2309.  handleVar      is the name of a variable which is to receive the handle to the 
  2310.                 timer. 
  2311.  
  2312.  interval       is the time interval in milliseconds. 
  2313.  
  2314.  semHandle      is a shared event semaphore handle as obtained from 
  2315.                 SemEventCreate or SemEventOpen. 
  2316.  
  2317.  type           is the timer type.  It must be one of the following keywords: 
  2318.  
  2319.           Repeat                  the timer will repeat; 
  2320.  
  2321.           Single                  the timer will execute only once; this is the 
  2322.                                   default. 
  2323.  
  2324.                 The keywords are case insensitive and may be abbreviated. 
  2325.  
  2326.  Returns 
  2327.  
  2328.  SemStartTimer returns the code supplied by the DosAsyncTimer or DosStartTimer 
  2329.  system directive. 
  2330.  
  2331.  Notes 
  2332.  
  2333.  If the return code is non-zero, handleVar is not created or modified. 
  2334.  
  2335.  See also 
  2336.  
  2337.  SemStopTimer, SemEventCreate, SemEventWait 
  2338.  
  2339.  Examples 
  2340.  
  2341.  To start a timer and wait until it fires (60 seconds): 
  2342.  
  2343.       call SemEventCreate 'timerSem', 'Shared'
  2344.       if result \= 0 then signal SemCreateError
  2345.  
  2346.       call SemStartTimer , 60 * 1000, timerSem
  2347.       if result \= 0 then signal TimerStartError
  2348.  
  2349.       call SemEventWait timerSem
  2350.       if result \= 0 then signal SemWaitError
  2351.  
  2352.  
  2353. ΓòÉΓòÉΓòÉ 6.23. SemStopTimer function ΓòÉΓòÉΓòÉ
  2354.  
  2355.  
  2356. Syntax 
  2357.  
  2358. rc = SemStopTimer(timerHandle) 
  2359.  
  2360. Description 
  2361.  
  2362. SemStopTimer is used to stop a timer started with SemStartTimer. 
  2363.  
  2364. Arguments 
  2365.  
  2366.  timerHandle    is the handle created by SemStartTimer. 
  2367.  
  2368.  Returns 
  2369.  
  2370.  SemStopTimer returns the code supplied by the DosStopTimer system directive. 
  2371.  
  2372.  See also 
  2373.  
  2374.  SemStartTimer